home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 125 / Computer Shopper CD-ROM Issue 125 (1998-07)(Dennis Publishing).iso / Business / Dazzler / DAZZLER.Z / CRectArray.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-26  |  1.4 KB  |  133 lines

  1. class CRectArray {
  2.    private CRect[] m_rcArray;
  3.    private int m_nNoElements;
  4.  
  5.    void SetSize(int var1) {
  6.       this.m_rcArray = new CRect[var1];
  7.       this.m_nNoElements = var1;
  8.    }
  9.  
  10.    CRect GetAt(int var1) {
  11.       CRect var2;
  12.       try {
  13.          var2 = this.m_rcArray[var1];
  14.       } catch (ArrayIndexOutOfBoundsException var3) {
  15.          var2 = null;
  16.       }
  17.  
  18.       return var2;
  19.    }
  20.  
  21.    boolean InsertAt(int var1, CRect var2) {
  22.       boolean var3 = false;
  23.       if (var1 >= 0) {
  24.          if (var1 > this.m_nNoElements - 1) {
  25.             var3 = this.SetAtGrow(var1, var2);
  26.          } else {
  27.             CRect[] var4 = new CRect[this.m_nNoElements];
  28.             System.arraycopy(this.m_rcArray, 0, var4, 0, this.m_nNoElements);
  29.             this.m_rcArray = new CRect[this.m_nNoElements + 1];
  30.             if (this.SetAt(var1, var2)) {
  31.                System.arraycopy(var4, 0, this.m_rcArray, 0, var1);
  32.                System.arraycopy(var4, var1, this.m_rcArray, var1 + 1, this.m_nNoElements - var1);
  33.                ++this.m_nNoElements;
  34.                var3 = true;
  35.             }
  36.          }
  37.       }
  38.  
  39.       return var3;
  40.    }
  41.  
  42.    boolean Add(CRect var1) {
  43.       return this.SetAtGrow(this.m_nNoElements, var1);
  44.    }
  45.  
  46.    boolean RemoveAt(int var1) {
  47.       boolean var2 = false;
  48.       if (var1 >= 0 && var1 < this.m_nNoElements) {
  49.          CRect[] var3 = new CRect[this.m_nNoElements];
  50.          System.arraycopy(this.m_rcArray, 0, var3, 0, this.m_nNoElements);
  51.          this.m_rcArray = new CRect[this.m_nNoElements - 1];
  52.          System.arraycopy(var3, 0, this.m_rcArray, 0, var1);
  53.          System.arraycopy(var3, var1 + 1, this.m_rcArray, var1, this.m_nNoElements - (var1 + 1));
  54.          this.m_nNoElements += -1;
  55.          var2 = true;
  56.       }
  57.  
  58.       return var2;
  59.    }
  60.  
  61.    boolean Copy(CRectArray var1) {
  62.       boolean var2 = false;
  63.       this.SetSize(var1.GetSize());
  64.  
  65.       for(int var3 = 0; var3 < this.m_nNoElements; ++var3) {
  66.          if (!this.SetAt(var3, var1.GetAt(var3))) {
  67.             var2 = false;
  68.             break;
  69.          }
  70.  
  71.          var2 = true;
  72.       }
  73.  
  74.       return var2;
  75.    }
  76.  
  77.    int GetSize() {
  78.       return this.m_nNoElements;
  79.    }
  80.  
  81.    boolean SetAtGrow(int var1, CRect var2) {
  82.       boolean var3 = false;
  83.       if (var1 >= 0) {
  84.          while(!var3) {
  85.             try {
  86.                this.m_rcArray[var1] = var2;
  87.                var3 = true;
  88.             } catch (ArrayIndexOutOfBoundsException var5) {
  89.                CRect[] var4 = new CRect[var1 + 1];
  90.                System.arraycopy(this.m_rcArray, 0, var4, 0, this.m_nNoElements);
  91.                this.m_rcArray = new CRect[var1 + 1];
  92.                System.arraycopy(var4, 0, this.m_rcArray, 0, this.m_nNoElements);
  93.                this.m_nNoElements = var1 + 1;
  94.                var3 = false;
  95.             }
  96.          }
  97.       }
  98.  
  99.       return var3;
  100.    }
  101.  
  102.    int GetUpperBound() {
  103.       return this.m_nNoElements - 1;
  104.    }
  105.  
  106.    void RemoveAll() {
  107.       this.SetSize(0);
  108.       this.m_rcArray = new CRect[0];
  109.    }
  110.  
  111.    CRectArray() {
  112.       this.m_rcArray = new CRect[0];
  113.       this.m_nNoElements = 0;
  114.    }
  115.  
  116.    CRectArray(int var1) {
  117.       this.SetSize(var1);
  118.    }
  119.  
  120.    boolean SetAt(int var1, CRect var2) {
  121.       boolean var3 = false;
  122.  
  123.       try {
  124.          this.m_rcArray[var1] = var2;
  125.          var3 = true;
  126.       } catch (ArrayIndexOutOfBoundsException var4) {
  127.          var3 = false;
  128.       }
  129.  
  130.       return var3;
  131.    }
  132. }
  133.